<?php

namespace app\admin\service;

use app\admin\model\BoxGameCate;
use app\admin\validate\BoxGameCateValidate;

class BoxGameCateService extends BaseService
{
    /**
     * 构造函数
     * LevelService constructor.
     */
    public function __construct()
    {
        $this->model = new BoxGameCate();
    }

    public function getList(): array
    {
        $param = request()->param();
        // 查询条件
        $map = [];
        if (isset($param['id']) && !empty($param['id'])) {
            $map[] = ['id', '=', $param['id']];
        }
        if (isset($param['status']) && !empty($param['status'])) {
            $map[] = ['status', '=', $param['status']];
        }
        if (isset($param['name']) && !empty($param['name'])) {
            $map[] = ['name', 'like', '%' . $param['name'] . '%'];
        }
        if (isset($param['began_time']) && !empty($param['began_time'])) {
            $map[] = ['create_time', '>=', strtotime($param['began_time'])];
        }
        if (isset($param['end_time']) && !empty($param['end_time'])) {
            $map[] = ['create_time', '<=', strtotime($param['end_time'])];
        }
        if (isset($param['device']) && !empty($param['device'])) {
            $map[] = ['device', 'like', '%'.$param['device'].'%'];
        }

        return parent::getList($map); // TODO: Change the autogenerated stub
    }

    public function edit()
    {
        $param = request()->param();
        $validate = new BoxGameCateValidate();
        if (!$validate->check($param)) {
            return message($validate->getError(), false, null, 1);
        }
        return parent::edit($param); // TODO: Change the autogenerated stub
    }

    public function status(){
        $param = request()->param();
        return parent::status($param); // TODO: Change the autogenerated stub

    }

}